<html>
<head><meta charset="utf-8"><title>What is the difference between AssocTypeItem and TypedefItem · rustdoc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/index.html">rustdoc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html">What is the difference between AssocTypeItem and TypedefItem</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221460344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221460344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221460344">(Jan 03 2021 at 17:05)</a>:</h4>
<p><span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> do you know the difference between <code>AssocTypeItem</code> and <code>TypedefItem(_, true)</code>?</p>



<a name="221460368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221460368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221460368">(Jan 03 2021 at 17:05)</a>:</h4>
<p>I would like to get rid of one or the other (preferably <code>TypedefItem(_, true)</code>)</p>



<a name="221460444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221460444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221460444">(Jan 03 2021 at 17:06)</a>:</h4>
<p><code>TypedefItem</code> is an <code>AssocTypeItem</code> for me. I discovered that it was badly used at the same time as you today haha</p>



<a name="221460451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221460451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221460451">(Jan 03 2021 at 17:06)</a>:</h4>
<p>hmm, ok</p>



<a name="221460458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221460458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221460458">(Jan 03 2021 at 17:06)</a>:</h4>
<p>I'll delete it and see what goes wrong <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="221460473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221460473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221460473">(Jan 03 2021 at 17:07)</a>:</h4>
<p>I approve this way of doing things XD</p>



<a name="221461855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221461855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221461855">(Jan 03 2021 at 17:37)</a>:</h4>
<p>I don't understand this well enough to fix it. There's different info in each: <code>TypedefItem</code> holds</p>
<ul>
<li>the original item (<code>type_</code>)</li>
<li><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/clean/types/struct.Generics.html"><code>Generics</code></a></li>
<li>the cleaned type (<code>item_type</code>)</li>
</ul>
<p>while <code>AssocTypeItem</code> only has the generic bounds and a place for the type default.</p>
<p>There's all sorts of things wrong here:</p>
<ul>
<li><code>TypedefItem</code> doesn't have the type default. Maybe this is what goes wrong in <a href="https://github.com/rust-lang/rust/issues/80379">https://github.com/rust-lang/rust/issues/80379</a> ?</li>
<li><code>TypedefItem</code> duplicates the original type by storing both the original and the cleaned version. It should only store one or the other.</li>
<li><code>AssocTypeItem</code> doesn't have the original type</li>
<li><code>AssocTypeItem</code> is missing any generic parameters. I think this will prevent rustdoc from documenting GATs.</li>
</ul>



<a name="221461917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221461917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221461917">(Jan 03 2021 at 17:38)</a>:</h4>
<p>maybe I'll start small and just remove the cleaned version from <code>TypedefItem</code></p>



<a name="221462056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221462056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221462056">(Jan 03 2021 at 17:41)</a>:</h4>
<p>wow this logic is just <em>so</em> convoluted</p>



<a name="221462182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221462182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221462182">(Jan 03 2021 at 17:43)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/bcd69750794b315d7c673351f86cacdf5232a0b7/src/librustdoc/clean/mod.rs#L1124"><code>impl Clean for hir::Impl</code></a> sees that it's an item, calculates the def id, passes it to <a href="https://github.com/rust-lang/rust/blob/bcd69750794b315d7c673351f86cacdf5232a0b7/src/librustdoc/clean/inline.rs#L277"><code>build_ty</code></a>, <em>recalculates</em> the type, passes it to <a href="https://github.com/rust-lang/rust/blob/bcd69750794b315d7c673351f86cacdf5232a0b7/src/librustdoc/clean/inline.rs#L272"><code>build_type_alias_item</code></a>, which then passes it <em>back</em> to <code>build_ty</code>, calculates the type I think a fourth time now, and only then actually does work in <code>impl Clean for Ty</code></p>



<a name="221463241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463241">(Jan 03 2021 at 18:05)</a>:</h4>
<p><span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> here's what goes wrong if I remove all that and just clone <code>type_</code>:</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code>comparing: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/test/rustdoc/deref-typedef.nightly/foo/struct.Bar.html ⟶   /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/test/rustdoc/deref-typedef/foo/struct.Bar.html
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

41
        &lt;div class="block items"&gt;
          &lt;a class="sidebar-title" href="#deref-methods"&gt;Methods from Deref&amp;lt;Target=FooC&amp;gt;&lt;/a&gt;
          &lt;div class="sidebar-links"&gt;
<span class="gd">-           &lt;a href="#method.foo_a"&gt;foo_a&lt;/a&gt;&lt;a href="#method.foo_b"&gt;foo_b&lt;/a&gt;&lt;a href="#method.foo_c"&gt;foo_c&lt;/a&gt;</span>
<span class="gi">+           &lt;a href="#method.foo_c"&gt;foo_c&lt;/a&gt;</span>
          &lt;/div&gt;&lt;a class="sidebar-title" href="#trait-implementations"&gt;Trait Implementations&lt;/a&gt;
          &lt;div class="sidebar-links"&gt;
            &lt;a href="#impl-Deref"&gt;Deref&lt;/a&gt;

91
        Methods from &lt;a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref"&gt;Deref&lt;/a&gt;&amp;lt;Target = &lt;a class="type" href="../foo/type.FooC.html" title="type foo::FooC"&gt;FooC&lt;/a&gt;&amp;gt;&lt;a href="#deref-methods" class="anchor"&gt;&lt;/a&gt;
      &lt;/h2&gt;
      &lt;div class="impl-items"&gt;
<span class="gd">-       &lt;h4 id="method.foo_a" class="method"&gt;</span>
<span class="gd">-         &lt;code&gt;pub fn &lt;a href="#method.foo_a" class="fnname"&gt;foo_a&lt;/a&gt;(&amp;amp;self)&lt;/code&gt;&lt;a class="srclink" href="../src/foo/deref-typedef.rs.html#18" title="goto source code"&gt;[src]&lt;/a&gt;</span>
<span class="gd">-       &lt;/h4&gt;</span>
<span class="gd">-     &lt;/div&gt;</span>
<span class="gd">-     &lt;div class="impl-items"&gt;</span>
<span class="gd">-       &lt;h4 id="method.foo_b" class="method"&gt;</span>
<span class="gd">-         &lt;code&gt;pub fn &lt;a href="#method.foo_b" class="fnname"&gt;foo_b&lt;/a&gt;(&amp;amp;self)&lt;/code&gt;&lt;a class="srclink" -ref="../src/foo/deref-typedef.rs.html#22" title="goto source code"&gt;[src]&lt;/a&gt;</span>
<span class="gd">-       &lt;/h4&gt;</span>
<span class="gd">-     &lt;/div&gt;</span>
<span class="gd">-     &lt;div class="impl-items"&gt;</span>
        &lt;h4 id="method.foo_c" class="method"&gt;
</code></pre></div>



<a name="221463279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463279">(Jan 03 2021 at 18:06)</a>:</h4>
<p>and I'm very unclear why that happens</p>



<a name="221463287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463287">(Jan 03 2021 at 18:06)</a>:</h4>
<p>git says you were the person who added it in <a href="https://github.com/rust-lang/rust/commit/12f029b7eecc01a38fbeec0eebe9041aa1bab7a5">https://github.com/rust-lang/rust/commit/12f029b7eecc01a38fbeec0eebe9041aa1bab7a5</a></p>



<a name="221463393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463393">(Jan 03 2021 at 18:09)</a>:</h4>
<p>well, to be fair, I added around 70% of rustdoc source code soooo... Let me check if I can remember this part.</p>



<a name="221463469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463469">(Jan 03 2021 at 18:11)</a>:</h4>
<p>Ok I remember: it's because we need the derefed type</p>



<a name="221463478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463478">(Jan 03 2021 at 18:11)</a>:</h4>
<p>if we don't get it, we can't get its methods</p>



<a name="221463523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463523">(Jan 03 2021 at 18:12)</a>:</h4>
<p>This is why you have the missing methods when you removing it.</p>



<a name="221463546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463546">(Jan 03 2021 at 18:13)</a>:</h4>
<p>but isn't <code>type_</code> already the deref type?</p>



<a name="221463562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463562">(Jan 03 2021 at 18:13)</a>:</h4>
<p>Apparently not, I'm still checking that</p>



<a name="221463563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463563">(Jan 03 2021 at 18:13)</a>:</h4>
<p>I'm confused what calling <code>type_of</code> actually does</p>



<a name="221463627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463627">(Jan 03 2021 at 18:14)</a>:</h4>
<p>btw, the full PR is here: <a href="https://github.com/rust-lang/rust/pull/68093">https://github.com/rust-lang/rust/pull/68093</a> and it's actually quite recent</p>



<a name="221463652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463652">(Jan 03 2021 at 18:15)</a>:</h4>
<p>So, I think we use <code>Typedef</code> because it's kinda the same logic between deref item and type alias</p>



<a name="221463656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221463656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221463656">(Jan 03 2021 at 18:15)</a>:</h4>
<p>not very beautiful though...</p>



<a name="221466248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221466248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221466248">(Jan 03 2021 at 19:18)</a>:</h4>
<p>so I found there are two differences between <code>type_</code> and <code>item_type</code>:</p>
<ol>
<li><code>Res</code> is <code>FooA</code> for type_ and <code>Err</code> for item_type</li>
<li>the path segments are <code>FooB</code> for type_ and <code>FooA</code> for item_type</li>
</ol>



<a name="221466258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221466258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221466258">(Jan 03 2021 at 19:18)</a>:</h4>
<p>I think the fix is that render shouldn't care about the path segments</p>



<a name="221466267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221466267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221466267">(Jan 03 2021 at 19:19)</a>:</h4>
<p>oh wait no I'm dumb, the third and largest difference is the DefIds: <code>FooB</code> for <code>type_</code> and <code>FooA</code> for item_type</p>



<a name="221466564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221466564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221466564">(Jan 03 2021 at 19:27)</a>:</h4>
<p>I think this might actually work by accident</p>



<a name="221466566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221466566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221466566">(Jan 03 2021 at 19:27)</a>:</h4>
<p>one sec</p>



<a name="221466681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221466681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221466681">(Jan 03 2021 at 19:30)</a>:</h4>
<p>oh no I'm just very confused</p>



<a name="221467096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467096">(Jan 03 2021 at 19:39)</a>:</h4>
<p>Let's just say I'm not very proud of that :-°</p>



<a name="221467146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467146">(Jan 03 2021 at 19:40)</a>:</h4>
<p>ok yes I was right, I confused myself.<br>
<span class="user-mention" data-user-id="210316">@GuillaumeGomez</span> this doesn't show any methods at all on <code>Bar</code>:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">FooA</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooB</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooA</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooC</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooB</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooD</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooC</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooE</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooD</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooF</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooE</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooG</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooF</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooH</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooG</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooI</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooH</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">type</span> <span class="nc">FooJ</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooI</span><span class="p">;</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">FooA</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo_a</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">FooB</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo_b</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">FooC</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo_c</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Bar</span><span class="p">;</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">std</span>::<span class="n">ops</span>::<span class="n">Deref</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Bar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Target</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">FooJ</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">deref</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nc">Self</span>::<span class="n">Target</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="fm">unimplemented!</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>What's going on is that each time you call <code>ty.clean().def_id()</code>, you get a different ID than before: it returns the ID of the item it's aliased to, not the original. So because you call <code>ty.clean().def_id().type_of().clean().def_id()</code> it works for two nested levels of aliases. But it breaks on anything more than two.</p>



<a name="221467158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467158">(Jan 03 2021 at 19:40)</a>:</h4>
<p>Yup</p>



<a name="221467176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467176">(Jan 03 2021 at 19:41)</a>:</h4>
<p>ok well good, that means that this can be done much more simply</p>



<a name="221467239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467239">(Jan 03 2021 at 19:42)</a>:</h4>
<p>recursiooooooon</p>



<a name="221467252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467252">(Jan 03 2021 at 19:42)</a>:</h4>
<p>well even simpler than that I think</p>



<a name="221467260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467260">(Jan 03 2021 at 19:43)</a>:</h4>
<div class="codehilite"><pre><span></span><code>rustdoc::clean::impl_Clean_for_TyAlias
├─0ms DEBUG rustdoc::clean def_id=DefId(0:5 ~ foo[8787]::FooB), ty=Ty {
│     hir_id: HirId {
│         owner: DefId(0:5 ~ foo[8787]::FooB),
│         local_id: 1,
│     },
│     kind: Path(
│         Resolved(
│             None,
│             Path {
│                 span: src/test/rustdoc/deref-typedef.rs:14:17: 14:21 (#0),
│                 res: Def(
│                     Struct,
│                     DefId(0:3 ~ foo[8787]::FooA),
│                 ),
</code></pre></div>



<a name="221467271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467271">(Jan 03 2021 at 19:43)</a>:</h4>
<p>oh wait this is for FooB, not FooC</p>



<a name="221467276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467276">(Jan 03 2021 at 19:43)</a>:</h4>
<p>so yeah I guess recursion :(</p>



<a name="221467281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467281">(Jan 03 2021 at 19:44)</a>:</h4>
<p>I was really wondering for one sec how you could get it without recursing</p>



<a name="221467323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467323">(Jan 03 2021 at 19:44)</a>:</h4>
<p>well I would <em>expect</em> there to be a compiler API for this</p>



<a name="221467325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467325">(Jan 03 2021 at 19:44)</a>:</h4>
<p>since it happens often, is expensive, and can easily be cached by short-circuiting</p>



<a name="221467344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467344">(Jan 03 2021 at 19:45)</a>:</h4>
<p>I guess there is one. But we still need to get all implementations made on each alias if any</p>



<a name="221467355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467355">(Jan 03 2021 at 19:45)</a>:</h4>
<p>I would expect those to be present on the final DefId</p>



<a name="221467361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467361">(Jan 03 2021 at 19:45)</a>:</h4>
<p>it doesn't make sense for the API to work any other way</p>



<a name="221467435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221467435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221467435">(Jan 03 2021 at 19:47)</a>:</h4>
<p>Well, sounds like a great new way to get things done :D</p>



<a name="221468003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468003">(Jan 03 2021 at 19:59)</a>:</h4>
<p>oh I bet it's <code>normalize()</code></p>



<a name="221468055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468055">(Jan 03 2021 at 20:00)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> If I have <code>type B = A; type C = B; ...</code>, will normalize() turn <code>Z</code> into <code>A</code>?</p>



<a name="221468504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468504">(Jan 03 2021 at 20:09)</a>:</h4>
<p>you won't even have to normalize here, do you?</p>



<a name="221468510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468510">(Jan 03 2021 at 20:09)</a>:</h4>
<p>what's the easier way?</p>



<a name="221468512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468512">(Jan 03 2021 at 20:09)</a>:</h4>
<p>the moment you convert to <code>ty::Ty</code> you should already end up with <code>A</code></p>



<a name="221468518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468518">(Jan 03 2021 at 20:09)</a>:</h4>
<p>... I should?</p>



<a name="221468519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468519">(Jan 03 2021 at 20:09)</a>:</h4>
<p>type aliases don't really exist after hir</p>



<a name="221468522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468522">(Jan 03 2021 at 20:09)</a>:</h4>
<p>that's not the behavior I'm seeing but maybe I'm just confused</p>



<a name="221468589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468589">(Jan 03 2021 at 20:10)</a>:</h4>
<p>hmm, maybe you are still using <code>hir::Ty</code>?</p>



<a name="221468594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468594">(Jan 03 2021 at 20:10)</a>:</h4>
<p>or i am really confused rn <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="221468610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468610">(Jan 03 2021 at 20:11)</a>:</h4>
<p>well all this code is a mess really lol <a href="#narrow/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem/near/221462182">https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem/near/221462182</a></p>



<a name="221468616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468616">(Jan 03 2021 at 20:11)</a>:</h4>
<p>let me start by just calling <code>type_of</code> and see if it helps</p>



<a name="221468769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468769">(Jan 03 2021 at 20:14)</a>:</h4>
<p>ok you are correct that it is <code>A</code> before I ever pass it to normalize</p>



<a name="221468775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221468775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221468775">(Jan 03 2021 at 20:14)</a>:</h4>
<p>which makes me think this is a bug elsewhere in rustdoc</p>



<a name="221469445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221469445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221469445">(Jan 03 2021 at 20:29)</a>:</h4>
<p>anddd I found it, rustdoc does this in three places as usual <span aria-label="face palm" class="emoji emoji-1f926" role="img" title="face palm">:face_palm:</span> </p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs</span>
<span class="gh">index f4eb1924e6f..d78ae11fc78 100644</span>
<span class="gd">--- a/src/librustdoc/clean/mod.rs</span>
<span class="gi">+++ b/src/librustdoc/clean/mod.rs</span>
<span class="gu">@@ -1118,10 +1118,11 @@ fn clean(&amp;self, cx: &amp;DocContext&lt;'_&gt;) -&gt; Item {</span>
                     }
                     MethodItem(m, Some(self.defaultness))
                 }
<span class="gd">-                hir::ImplItemKind::TyAlias(ref ty) =&gt; {</span>
<span class="gd">-                    let type_ = ty.clean(cx);</span>
<span class="gd">-                    let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));</span>
<span class="gd">-                    TypedefItem(Typedef { type_, generics: Generics::default(), item_type }, true)</span>
<span class="gi">+                hir::ImplItemKind::TyAlias(ref hir_ty) =&gt; {</span>
<span class="gi">+                    let type_ = hir_ty.clean(cx);</span>
<span class="gi">+                    let item_type = hir_ty_to_ty(cx.tcx, hir_ty).clean(cx);</span>
<span class="gi">+                    TypedefItem(Typedef { type_: type_.clone(), generics: Generics::default(), item_type: Some(item_type) }, true)</span>
                 }
             };
             Item::from_def_id_and_parts(local_did, Some(self.ident.name), inner, cx)
</code></pre></div>



<a name="221469569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221469569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221469569">(Jan 03 2021 at 20:31)</a>:</h4>
<p>thanks for the help everyone :)</p>



<a name="221470736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221470736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221470736">(Jan 03 2021 at 21:00)</a>:</h4>
<p>I have an idea to simplify this further, but unfortunately it means the bug in <a href="https://github.com/rust-lang/rust/issues/80379">https://github.com/rust-lang/rust/issues/80379</a> will apply to the current crate as well :(</p>



<a name="221470944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221470944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221470944">(Jan 03 2021 at 21:05)</a>:</h4>
<p>if you don't mind looking into  type aliases in rustdoc, can you convert all tys to <code>ty::Ty</code> and then walk the substs for <code>Adt</code>s backwards during printing to remove all arguments which are equal to the default param?</p>



<a name="221471041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471041">(Jan 03 2021 at 21:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem/near/221470944">said</a>:</p>
<blockquote>
<p>if you don't mind looking into  type aliases in rustdoc, can you convert all tys to <code>ty::Ty</code> and then walk the substs for <code>Adt</code>s backwards during printing to remove all arguments which are equal to the default param?</p>
</blockquote>
<p>that will break if someone explicitly writes <code>Vec&lt;usize, Global&gt;</code>, though, right?</p>



<a name="221471049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471049">(Jan 03 2021 at 21:07)</a>:</h4>
<p>I want to replace it only if it's been injected by the compiler</p>



<a name="221471057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471057">(Jan 03 2021 at 21:08)</a>:</h4>
<p>I guess there's not really a way to do that across crates</p>



<a name="221471091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471091">(Jan 03 2021 at 21:08)</a>:</h4>
<p>yeah</p>



<a name="221471102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471102">(Jan 03 2021 at 21:08)</a>:</h4>
<p>though is printing <code>Vec&lt;usize, Global&gt;</code> desirable even if someone explicitly prints it?</p>



<a name="221471107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471107">(Jan 03 2021 at 21:08)</a>:</h4>
<p>yeah, it probably makes sense to elide it no matter what</p>



<a name="221471111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471111">(Jan 03 2021 at 21:08)</a>:</h4>
<p>I don't have time to do this today probably but that sounds like the right approach :)</p>



<a name="221471122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471122">(Jan 03 2021 at 21:09)</a>:</h4>
<p>changing the param defaults is a breaking change so there shouldn't be too many reasons to explicitly specify the param default</p>



<a name="221471190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471190">(Jan 03 2021 at 21:11)</a>:</h4>
<p>I can imagine it being confusing if <code>hashbrown</code> changes the default hasher across releases or something</p>



<a name="221471200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471200">(Jan 03 2021 at 21:11)</a>:</h4>
<p>but that still seems better than just never eliding it</p>



<a name="221471286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/266220-rustdoc/topic/What%20is%20the%20difference%20between%20AssocTypeItem%20and%20TypedefItem/near/221471286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/266220-rustdoc/topic/What.20is.20the.20difference.20between.20AssocTypeItem.20and.20TypedefItem.html#221471286">(Jan 03 2021 at 21:13)</a>:</h4>
<p>yeah, it is a bit unfortunate</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>